<?php 
/* P3(c)

******************************************************************************
                                                                                      
                         __                                                        
                        /__)                                                       
                       /__        P3 - moving Technologie            
                        __)                                                          
                        __)                                                          
                                                                                        
                                                                                        
       Copyright 2009 by p3.co.at                                                                                 
                                                                                        
       visit www.p3.co.at to get more Informations 
       about Teriko - Betriebsdatenerfassung                                                                                 
       - it's not allowed to change this scripts
       - it's not allowed to remove this copyright-tag

       -- you can download the complete license   
          under http://www.teriko.org

 (c) by Patrik Pfaffenbauer and P3 (http://www.p3.co.at)

 | Programname: P3.Teriko
 | Authtor: P3.Verein
 | Coder: Patrik Pfaffenbauer
 | Version: 0.1

 | Change Index
 |_____________________________________________
 |                                             |
 |4.3.2010 Erstellung | Patrik Pfaffenbauer    |
 |_____________________________________________|

******************************************************************************

P3(c) */
include("_config.php");

if($_GET['action'] == 'time')
{
	echo date('d.m.Y H:i', time());
}
else if($_GET['s'] == "online")
{
	$res = $GLOBALS['db']->Query("SELECT * FROM ".$tblproject);
	
	$rows = array();
	while($r = mysql_fetch_assoc($res)) 
	{
    	$rows[] = $r;
	}	
	
	echo json_encode($rows);
}
else if($_GET['s'] == "paintJob")
{
	$online = new Online();
	
	if(!$online->allowed)
		return;

	$online->PaintActualJob($_GET['id']);
}
else if($_GET['s'] == "pauseJob")
{
	$online = new Online();
	
	if(!$online->allowed)
		return;
		
	$online->PauseJob($_GET['id'], $_GET['pauseid']);
}
else if($_POST['s'] == "stopJob")
{
	$online = new Online();
	
	if(!$online->allowed)
		return;
		
	$online->StopJob($_POST['id'], $_POST['comment']);
}
else if($_POST['s'] == "commentJob")
{
	$online = new Online();
	
	if(!$online->allowed)
		return;
		
	$online->CommentJob($_POST['id'], $_POST['comment']);
}
else if($_POST['s'] == "startLastJob")
{
	$online = new Online();
	
	if(!$online->allowed)
		return;
		
	$online->StartLastJob($_POST['comment']);
}
else if($_POST['s'] == "help")
{
	$help = new Help();
	
	if(!$help->permission->editPermission)
	{
		echo $GLOBALS['lang']->GetLanguage("Permission", "noSavePermission");
		return;
	}
	
	$help->SaveHelp($_POST['id']);
}

?>